package main

import (
	"demo/util"
	"flag"
	"fmt"
	"os"
	"time"
)

func TestFlag() {
	if len(os.Args) > 0 {
		for index, agr := range os.Args {
			fmt.Printf("args[%d]=%#v\n", index, agr)
		}
	}
	var name2 string
	var age2 int
	var m bool
	var delay2 time.Duration

	flag.StringVar(&name2, "name2", "zhangsan", "name")
	flag.IntVar(&age2, "age2", 19, "age")
	flag.BoolVar(&m, "m", false, "married")
	flag.DurationVar(&delay2, "delay2", 0, "delay")
	fmt.Println(name2, age2, m, delay2)

	flag.Parse()
	fmt.Println("flags=", name2, age2, m, delay2)
	fmt.Println(flag.NFlag())

	fmt.Println(flag.Args())
	fmt.Println(flag.NArg())
	for i := 0; i < flag.NArg(); i++ {
		fmt.Println(flag.Arg(i))
	}
}

func main() {
	//TestFlag()

	util.TestJson()
	util.TestGob()
	util.TestMsgPack()

	//util.TestLog()

	util.TestTime()
	//fmt.Println(util.Mode)

	//util.TestMath()

	util.TestSort()

	util.TestHasher()
}
